package com.jzh.eurekaclient.web;

import com.jzh.eurekaclient.util.NetworkUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class DcController {
    private static final Logger logger = LogManager.getLogger(DcController.class);
    @Autowired
    DiscoveryClient discoveryClient;
    @Value("${spring.application.name}")
    private String serviceName;
    @Value("${server.port}")
    private String port;
    @GetMapping("/dc")
    public String dc(HttpServletRequest request) throws Exception{
        String services = "Services: " + discoveryClient.getServices();
        logger.info("****************************/add, port:" + port + ", serviceName:" + serviceName);
        return services;
    }
}
